<?php

namespace Admin\Models\res;

use Admin\Models\BaseModel;
class XhresReferenceNote extends BaseModel
{

    /**
     *
     * @var integer or string
     */
    public $iId;
    public $iStatus;
    public $iBookId;
    public $iDateType;
    public $iBookSubject;
    public $iBookClass;
    public $sSchoolPower;
    public $sDemandFinishDate;
    public $sBookProgressDate;
    public $sBookSuspendDate;
    public $sBookFinishDate;
    public $sDemandCheckUser;
    public $sDemandCheckDate;
    public $sBookCheckDate;
    public $sBookCheckUser;
    /**
     *
     * @var integer
     */
    public $bDelete;

    /**
     *
     * @var string
     */
    public $tCreateDate;

    /**
     *
     * @var string
     */
    public $iCreateUserId;

    /**
     *
     * @var string
     */
    public $tLastModifyDate;

    /**
     *
     * @var string
     */
    public $iLastModifyUserId;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        parent::initialize();
        $this->setSource("XHRes_ReferenceNote");
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'XHRes_ReferenceNote';
    }

    /**
     *
     * @param null $parameters
     *
     * @return \Phalcon\Mvc\Model\ResultsetInterface |XhresReferenceNote
     *
     * create by qgz 20180921
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     *
     * @param null $parameters
     *
     * @return \Phalcon\Mvc\Model | XhresReferenceNote
     *
     * create by qgz 20180921
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * 重写save方法，是否需要更新操作人和时间（比如跑脚本）
     *
     * @param null $data
     * @param null $whiteList
     * @param bool $updateModifyUser
     *
     * @return bool
     *
     * create by qgz 20181009
     */
    public function save($data = null, $whiteList = null, $updateModifyUser = false)
    {
        if ($updateModifyUser) {
            $this->beforeUpdate();
        } else {
            parent::beforeUpdate();
        }
        return parent::save($data, $whiteList); // TODO: Change the autogenerated stub
    }

    public function beforeUpdate()
    {
        if (property_exists($this, 'tLastModifyDate')) {
            return true;
        }
        if (property_exists($this, 'iLastModifyUserId')) {
            return true;
        }
        return true;
    }

}
